<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.util.*"%>
<%@page import="java.net.*"%>
<%@page import="org.xtframe.util.ContextUtil"%>
<%@page import="org.xtframe.entity.Application"%>
<%@page import="org.xtframe.entity.ApplicationConfig"%>
<%@page import="org.xtframe.entity.User"%>
<%@page import="org.xtframe.common.EncryptCount"%>
<%@page import="org.xtframe.util.ApplicationConfigUtil"%>
<%
String basePath = request.getContextPath();
Map<String, Object> model = (Map<String, Object>)request.getAttribute("model");
Map<String, Object> param = (Map<String, Object>)model.get("_param");
List<Map<String, Object>> login_info = (List<Map<String, Object>>) model.get("login_info");
String fw = param.containsKey("fw") ? param.get("fw").toString() : "";
if(login_info.size() > 0) {
	Application app = ContextUtil.getApplication();
	String username = param.get("username").toString();
	String pwd = param.containsKey("pwd") ? param.get("pwd").toString() : "";
	User user = new User(app);
	if (user.init(username, EncryptCount.encryptMD5(pwd))) {
		session.removeAttribute(ApplicationConfig.LOGIN_USER);
		session.setAttribute(ApplicationConfig.LOGIN_USER, user);
		if(fw.isEmpty()) {
			response.setHeader("refresh","0;url=" + basePath + "/index.jsp");
		} else {
			response.setHeader("refresh","0;url=" + basePath + fw);
		}
	} else {
		String info = URLEncoder.encode("您的该帐号或密码错误,请重新登录。", "utf-8");
		response.setHeader("refresh","0;url=" + basePath + "/p100012.html?fw=" + URLEncoder.encode(fw, "utf-8") + "&username=" + URLEncoder.encode(username, "utf-8") + "&info=" + info);
	}
} else {
	String username = param.containsKey("username") ? URLEncoder.encode(param.get("username").toString(), "utf-8") : "";
	String info = URLEncoder.encode("您的该帐号不存在,请重新登录。", "utf-8");
	response.setHeader("refresh","0;url=" + basePath + "/p100012.html?fw=" + URLEncoder.encode(fw, "utf-8") + "&username=" + username + "&info=" + info);
}
%>